//Nathan Popham
//4003-573-01: Procedural Shading
//Lab 3: Task 1 
//
//rotatableTexture
// This paints an object with the color of the given texture and provides the 
// ability to flip and/or rotate the applied texture. Set either of the flips
// or rotate to >0.0 to active them.
//
// flipS -- flip the texture's S axis
// flipT -- flip the texture's T axis
// rotate -- exchange the texture's S and T axes (applied before flipping!)

surface
rotatableTexture (float flipS = 0.0,
                        flipT = 0.0,
                        rotate = 0.0;
                  string texturename = "";)
{
    color Ct = Cs;


    if(texturename != "")
    {
        float ss = s;
        float tt = t;
        
        if(rotate > 0.0)
        {
            float temp = ss;
            ss = tt;
            tt = temp;
        }

        if(flipS > 0.0)
            ss = 1 - s;
        if(flipT > 0.0)
            tt = 1 - t;


        Ct *= color texture(texturename, ss, tt);
    }

    Oi = Os;
    Ci = Ct * Oi;

}
